import java.util.ArrayList;
import java.util.List;

public class project {
    public int[] productExceptSelf(int[] nums) {
        int left=1;
        int right=1;
        int[] arr=new int[nums.length];
        for(int i=0;i<nums.length;i++){
            arr[i]=left;
            left*=nums[i];
        }
        for(int i=nums.length-1;i>0;i--){
            right*=nums[i];
            arr[i-1]*=right;
        }
        return arr;
    }
















    public int maxProfit(int[] prices, int fee) {
        int prev=prices[0]+fee;
        int ret=0;
        for(int i=1;i<prices.length;i++){
            if(prices[i]+fee<prev){
                prev=prices[i]+fee;
            }else if(prices[i]>prev){
                ret+=prices[i]-prev;
                prev=prices[i];
            }
        }
        return ret;
    }

















    public List<Integer> lexicalOrder(int n) {
        List<Integer> list=new ArrayList<>();
        dfs(list,0,1,n);
        return  list;
    }
    public void dfs(List<Integer> list,int tmp,int start,int end){
        if(tmp>end){
            return;
        }
        for(int i=start;i<10;i++){
            int ret=i+tmp;
            if(ret<=end){
                list.add(ret);
                dfs(list,ret*10,0,end);
            }
        }
    }
}
